package com.schx.budget.controller

import com.schx.budget.pojo.Budget
import com.schx.budget.pojo.BudgetTarget
import com.schx.budget.service.BudgetService
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.ResponseBody
import javax.annotation.Resource

@Controller
class BudgetController {

    @Resource
    lateinit var budgetService: BudgetService

    /**
     * 获取各项目实际费用
     */
    @GetMapping("/getCostList")
    @ResponseBody
    fun getCostList(orgid: String): MutableMap<String, Any?> {
        return budgetService.getCostList(orgid)
    }

    /**
     * 获取各项目费用明细每月详情
     */
    @GetMapping("/getCostDetail")
    @ResponseBody
    fun getCostDetail(type: String, orgid: String): MutableMap<String, Any?> {
        return budgetService.getCostDetail(type, orgid)
    }

    /**
     * 获取各项目费用每月明细
     */
    @GetMapping("/getCostDetailByMonth")
    @ResponseBody
    fun getCostDetailByMonth(project: String, orgid: String): List<Budget> {
        return budgetService.getCostDetailByMonth(project,orgid)
    }


    /**
     * 获取各项目实际收入
     */
    @GetMapping("/getIncomeList")
    @ResponseBody
    fun getIncomeList(orgid: String): MutableMap<String, Any?> {
        return budgetService.getIncomeList(orgid)
    }


    /**
     * 获取各项目收入明细
     */
    @GetMapping("/getIncomeDetail")
    @ResponseBody
    fun getIncomeDetail(type: String, orgid: String): MutableMap<String, Any?> {
        return budgetService.getIncomeDetail(type,orgid)
    }

    /**
     * 获取各项目毛利每月明细
     */
    @GetMapping("/getInDetailByMonth")
    @ResponseBody
    fun getInDetailByMonth(project: String, orgid: String): List<Budget> {
        return budgetService.getInDetailByMonth(project,orgid)
    }

    /**
     * 获取各项目毛利每月每人明细
     */
    @GetMapping("/getIncomeByPerson")
    @ResponseBody
    fun getIncomeByPerson(project: String, month: String, orgid: String): List<Budget> {
        return budgetService.getIncomeByPerson(project, month,orgid)
    }

    /**
     * 获取执行结果
     */
    @GetMapping("/getResultDetail")
    @ResponseBody
    fun getResultDetail(orgid: String, type: String): List<BudgetTarget> {
        return budgetService.getResultDetail(orgid,type)
    }

    /**
     * 获取执行结果所有
     */
    @GetMapping("/getResultAll")
    @ResponseBody
    fun getResultAll(orgid: String): List<BudgetTarget> {
        return budgetService.getResultAll(orgid)
    }

}
